import axios from 'axios'
import mitt from 'mitt'
//  请求数据公共方法
async function ajax (options) {
  const { url, type = 'get', params = {}, data = {}, list } = options
  try {
    const resule = await axios({
      method: type,
      url: url,
      data: data,
      params: params
    })
    if (resule.data.errno === 0) { list.value = resule.data.data }
  } catch (e) { console.log(e) }
}

// 总线控制
const bus = mitt()

export { ajax, bus }
